package com.hexiang.web;


import com.alibaba.csp.sentinel.EntryType;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.hexiang.handler.HelloBlockHandler;
import com.hexiang.service.HelloService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class HelloController {

    @Resource
    private HelloService helloService;

    @GetMapping("/sayHello")
    @SentinelResource(value = "api.hello.sayHello", entryType = EntryType.IN, blockHandlerClass = HelloBlockHandler.class, blockHandler = "sayHello")
    public String sayHello() {
        return helloService.sayHello();
    }


    @GetMapping("/err")
    public String err() {
        return helloService.err();
    }

}
